package com.hxkj.controller.article;

import com.hxkj.domain.po.Leaflet;
import com.hxkj.service.article.LeafletService;
import com.platform.common.domain.result.ResultPageStruct;
import com.platform.common.domain.to.PageTo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.Callable;

/**
 * 单页控制层
 * <p>
 * created by zzx on 2018/6/6.
 */
@RestController
@RequestMapping("/leaflet")
public class LeafletController {


    @Autowired
    private LeafletService leafletService;


    /**
     * 获取单页列表
     *
     * @param leaflet 单页对象 和 分页信息
     * @return 翻页数据
     * @throws Exception
     */
    @RequestMapping(value = "/getlist", method = RequestMethod.POST)
    public Callable<ResultPageStruct<Leaflet>> getLeafletList(@ModelAttribute Leaflet leaflet, @ModelAttribute PageTo pageParam) throws Exception {
        return () -> leafletService.getLeafletList(leaflet == null ? new Leaflet() : leaflet, pageParam);
    }


    /**
     * 获取一条单页信息
     *
     * @param leaflet
     * @return 单页信息
     * @throws Exception
     */
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    public Callable<Leaflet> getLeaflet(@ModelAttribute Leaflet leaflet) throws Exception {
        return () -> leafletService.getLeaflet(leaflet);
    }

    /**
     * 新增单页
     *
     * @param Leaflet 单页信息
     * @throws Exception
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public void saveLeaflet(@ModelAttribute Leaflet Leaflet) throws Exception {
         leafletService.saveLeaflet(Leaflet);
    }

    /**
     * 删除单页
     *
     * @param Leaflet 单页信息
     * @throws Exception
     */
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public void removerLeaflet(@ModelAttribute Leaflet Leaflet) throws Exception {
        leafletService.removerLeaflet(Leaflet);
    }


    /**
     * 修改单页
     *
     * @param Leaflet 单页信息
     * @throws Exception
     */
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public void updateLeaflet(@ModelAttribute Leaflet Leaflet) throws Exception {
         leafletService.updateLeaflet(Leaflet);
    }

}






